#include "Btree.h"
#include<iostream>
using namespace std;
void Btree::CreatBtree(int x)
{
	tree* newnode = new tree;
	newnode->data = x;
	newnode->left = NULL;
	newnode->right = NULL;
	if (root == NULL)
	{
		root = newnode;
	}
	else 
	{
		tree* back;
		tree* current= root;
		while (current!=NULL)
		{
			back = current;
			if (current->data > x)
			{
				current = current->left;
			}
			else
			{
				current = current->right;
			}
		}
			if (back->data > x)
			{
				back->left = newnode;
			}
			else
			{
			back->right = newnode;
			}
		}
	}
void Btree::Preorder(tree* Temp)
{
	if (Temp != NULL)
	{
		cout << Temp->data << " ";
		Preorder(Temp->left);
		Preorder(Temp->right);
	}
}
